package com.rw.coco.handler.message.reply;

import com.rw.coco.handler.message.event.CocoGroupMessageEvent;
import com.rw.coco.handler.message.event.CocoMessageEvent;

public abstract class GroupReplyHandler implements ReplyHandler {
    /**
     * 触发的条件
     */
    @Override
    public boolean trigger(CocoMessageEvent cocoMessageEvent) {
        if (cocoMessageEvent instanceof CocoGroupMessageEvent) {
            CocoGroupMessageEvent groupEvent = (CocoGroupMessageEvent) cocoMessageEvent;
            return groupTrigger(groupEvent);
        }
        return false;
    }

    /**
     * 触发逻辑
     */
    @Override
    public void handler(CocoMessageEvent cocoMessageEvent) {
        if (cocoMessageEvent instanceof CocoGroupMessageEvent) {
            CocoGroupMessageEvent groupEvent = (CocoGroupMessageEvent) cocoMessageEvent;
            groupHandler(groupEvent);
        }
    }

    protected abstract boolean groupTrigger(CocoGroupMessageEvent groupEvent);

    protected abstract void groupHandler(CocoGroupMessageEvent groupEvent);
}
